package com.dev.liveshow.ui.activity;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

import com.dev.liveshow.R;
import com.dev.liveshow.databinding.ActivityMainBinding;
import com.dev.liveshow.ui.activity.AnchorActivity;

public class MainActivity extends AppCompatActivity {

    private ActivityMainBinding binding;
    private String roomName;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
        binding.startLive.setOnClickListener(v -> {
            roomName = binding.roomName.getText().toString();
            if (roomName.isEmpty()) {
                Toast.makeText(this,"房间名不能为空",Toast.LENGTH_SHORT).show();
            } else {
                Log.e("Main", "房间名为"+roomName);
                Intent intent = new Intent(this, AnchorActivity.class);
                intent.putExtra("roomName", roomName);
                startActivity(intent);
            }
        });
    }
}